<!DOCTYPE html>
<html class="x-admin-sm">
<!-- 商家审核页面 -->

<head>
	<meta charset="UTF-8">
	<title>商家审核页面</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport"
		content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
	<link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
	<link href="css/newStyle.css" rel="stylesheet">
	<link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
	<link rel="stylesheet" href="./css/font.css">
	<link rel="stylesheet" href="./css/xadmin.css">
	<link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<!-- 引入jq -->
	<script src="https://cdn.bootcss.com/jquery/3.4.0/jquery.min.js"></script>
	<script src="js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="js/bootstrap.min.js?v=3.3.6"></script>
	<script src="js/common.js" type="text/javascript" charset="utf-8"></script>
	<script src="./lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="./js/xadmin.js"></script>
	<!-- <script type="text/javascript" src="./js/common.js"></script> -->
	<style>
		.fl {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		/* 筛选模块 */
		.searchPart {
			border: 1px solid #ccc;
			margin: 15px 15px 5px 15px;
			background-color: #fff;
		}
		.layui-form-item {
			margin-bottom: 3px;
		}
		/* 表格部分 */
		.FormTablePart,
		.TotalTablePart,
		.FanTablePart {
			margin: 15px 15px;
		}
		.FormTablePart {
			border: 1px solid #ddd;
			height: 40vh;
			text-align: center;
		}
		.userImg .layui-icon {
			font-size: 70px;
			color: #ccc;
		}
		.userNum {
			font-size: 16px;
			margin: 15px 0;
		}
		.userText {
			width: 100px;
			height: 25px;
			line-height: 25px;
			background: #f04844;
			border-radius: 10px;
			margin: 0 auto;
			color: #fff;
		}
		.FormTablePartLf {
			padding-top: 20px;
			flex: 3;
		}
		.FormTablePartRg {
			flex: 7;
			height: 100%;
			margin-top: 20px;
			margin-left: 20px;
		}
		.layui-table-view .layui-table {
			width: 100%;
			height: 100%;
		}
		.totalTitle,
		.fanTitle {
			font-size: 16px;
			color: #666;
		}
		.sfz {
			width: 200px;
			height: 120px;
			background-color: #000;
			margin: 50px 30px;
			float: left;
			overflow: hidden;
		}
		.sfz img {
			width: 100%;
			height: 100%;
			display: block;
		}
		.layui-input {
			line-height: 30px;
		}
		.userImg #storePic {
			width: 100px;
			height: 100px;
			border-radius: 50%;
		}
		.opera_btn {
			display: inline-block;
			cursor: pointer;
			height: 40px !important;
			line-height: 40px;
			width: 140px !important;
			border-radius: 5px;
		}

		.ps_btn {
			display: inline-block;
			height: 40px !important;
			line-height: 40px;
			width: 140px !important;
			border-radius: 5px;
			background-color: #1abc9c;
			color: #fff;
			cursor: pointer;
		}
		body {
			padding-right: 0px !important;
			/* 强制设置右侧填充为0，这样弹窗的代码就改不动它了 */
			overflow-y: scroll !important;
			/* 所有页面都显示滚动条 */
		}
	</style>
</head>

<body>
	<!-- 商家审核页面 -->
	<!-- 导航条模块 -->
	<div class="x-nav" style="padding-top: 1px;  position: fixed; top: 0;width: 100%;">

		<a style="display: inline-block; " class="layui-btn layui-btn-small">
			<cite>商家审核</cite>
		</a>
		<a class="layui-btn " style="line-height:1.6em;margin-top:3px;float:right; position: relative; left: -30px;"
			onclick="location.reload()" title="刷新">
			<i class="layui-icon layui-icon-refresh" style="line-height:30px">刷新</i>
		</a>

	</div>

	<!-- 导购员信息模块 -->
	<div class="FormTablePart fl" style="margin-top: 60px;">
		<div class="FormTablePartLf">
			<div class="userImg">
				<img class="layui-icon layui-icon-username" id="storePic" src="">
			</div>
			<div class="userNum" id="storeName">格力旗舰店</div>

		</div>
		<div class="FormTablePartRg">
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item fl">
					<div class="layui-inline">
						<label class="layui-form-label">店铺名称</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeName2"></p>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">店铺账号</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="loginName"></p>
						</div>
					</div>
				</div>

				<div class="layui-form-item fl">
					<div class="layui-inline">
						<label class="layui-form-label">营业执照编号</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="papersCreditCode"></p>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">电话</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeCertPhone"></p>
						</div>
					</div>
				</div>

				<div class="layui-form-item fl">
					<div class="layui-inline">
						<label class="layui-form-label">商家支付宝</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeAlipayCode"></p>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">支付宝姓名</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeAlipayName"></p>
						</div>
					</div>
				</div>

				<div class="layui-form-item fl">
					<div class="layui-inline">
						<label class="layui-form-label">法人姓名</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeCertName"></p>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">联系电话</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeCustomerPhone"></p>
						</div>
					</div>
				</div>

				<div class="layui-form-item fl">
					<div class="layui-inline">
						<label class="layui-form-label">所在地址</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeAddress"></p>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">定位信息</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="locateInformation"></p>
						</div>
					</div>
				</div>
				<div class="layui-form-item fl">
					<div class="layui-inline">
						<label class="layui-form-label">服务费</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="storeMoney" style="text-align: center;"></p>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">注册时间</label>
						<div class="layui-input-inline">
							<p class="layui-input" id="time"></p>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>

	<div class="FormTablePart fl">
		<div class="FormTablePartLf">
			<p>营业执照</p>
		</div>
		<div style="height: 100%;width: 1px;overflow: hidden;background-color: #ddd;"></div>
		<div class="FormTablePartRg businessLicense">
			<!-- <div class="sfz"><img id="papersPic" src="" onclick="previewImg(this)"></div> -->
		</div>
	</div>
	<div class="FormTablePart fl">
		<div class="FormTablePartLf">
			<p>身份证照</p>
		</div>
		<div style="height: 100%;width: 1px;overflow: hidden;background-color: #ddd;"></div>
		<div class="FormTablePartRg" id="storeInPicCode">
			<!-- <div class="sfz"><img id="idCardPic" src="" onclick="previewImg(this)"></div>
			<div class="sfz"><img id="idCardPic2" src="" onclick="previewImg(this)"></div> -->
		</div>
	</div>
	<div class="FormTablePart fl">
		<div class="FormTablePartLf">
			<p>店铺封面</p>
		</div>
		<div style="height: 100%;width: 1px;overflow: hidden;background-color: #ddd;"></div>
		<div class="FormTablePartRg">
			<div class="sfz"><img id="storeDecorationPic" src="" onclick="previewImg(this)"></div>
		</div>
	</div>
	<div class="FormTablePart fl">
		<div class="FormTablePartLf">
			<p>门店照片</p>
		</div>
		<div style="height: 100%;width: 1px;overflow: hidden;background-color: #ddd;"></div>
		<div class="FormTablePartRg" id="storeInPic">

		</div>
	</div>
	<div style="margin: 15px;">
		<table class="layui-hide" id="test"></table>
	</div>

	<div class="layui-form-item" style="margin:50px 0 ; text-align: center;">
		<text class="opera_btn" data-toggle="modal" data-target="#refuse_dialog">拒绝</text>
		<span style="display: inline-block;width: 60px;"></span>
		<!-- <button class="pass_btn" data-toggle="modal" data-target="#pass_dialog">审核通过</button> -->
		<text class="ps_btn" data-toggle="modal" data-target="#pass_dialog">审核通过</text>
	</div>

	<!-- 点击拒绝的弹窗 -->
	<div class="modal inmodal fade" id="refuse_dialog" tabindex="-1" role="dialog" aria-hidden="true"
		style="margin-top: 50px;">
		<div class="modal-dialog modal-sm">
			<div class="modal-content br8">
				<div class="modal-header p10 bdno">
					<button type="button" class="close" data-dismiss="modal"><span
							aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<span class="modal-title f18">审核拒绝</span>
				</div>
				<div class="modal-body bg_f p0">
					<div class="ibox-content p30">
						<form class="form-horizontal m-t" id="refuse_form" method="post">
							<div class="form-group ">
								<label class="col-sm-3 control-label pull-left">拒绝原因:</label>
								<div class="col-sm-8 pull-left">
									<!-- 原因 -->
									<textarea type="text" class="form-control edit_sort reason" name="sort" value=""
										required="" aria-required="true" style="height: 100px;"
										placeholder="必填"> </textarea>
								</div>
							</div>

							<div class="form-group ">
								<label class="col-sm-3 control-label ">审核人员:</label>
								<div class="col-sm-8 pull-left" style="position: relative;">
									<p class="form-control user_refuse" name="cateName" style="height: 30px;"> </p>
									<p style="margin-top: 5px;margin-left: 3px;color: #ccc;">审核人员不出现在App端</p>
								</div>
							</div>
						</form>
					</div>
				</div>
				<div class="modal-footer bdno tac pt0040">
					<button type="button" class=" btn-white clear_btn_style dialog_btn" data-dismiss="modal">取消</button>
					<button type="button" class=" btn-primary clear_btn_style bdno dialog_btn ml30" id="refuse_btn"
						style="background-color: #13bc75;">保存</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 点击通过的弹窗 -->
	<div class="modal inmodal fade" id="pass_dialog" tabindex="-1" role="dialog" aria-hidden="true"
		style="margin-top: 50px;">
		<div class="modal-dialog modal-sm">
			<div class="modal-content br8">
				<div class="modal-header p10 bdno">
					<button type="button" class="close" data-dismiss="modal"><span
							aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<span class="modal-title f18">审核通过</span>
				</div>
				<div class="modal-body bg_f p0">
					<div class="ibox-content p30">
						<form class="form-horizontal m-t" id="pass_form" method="post">
							<div class="form-group ">
								<label class="col-sm-3 control-label ">商家名称:</label>
								<div class="col-sm-8 pull-left">
									<text type="text" class="merchant_name"
										style="margin-top: 9px;display: inline-block;"></text>
								</div>
							</div>
							<div class="form-group ">
								<label class="col-sm-3 control-label ">服务费:</label>
								<div class="col-sm-8 pull-left" style="position: relative;">
									<input type='number' class="form-control edit_cateName sever_code" name="cateName"
										value="" required="" aria-required="true" placeholder="只能填数字">
									<span style="position: absolute; right: 0;top: 10px;font-size: 14px;">%</span>
									<p style="margin-top: 5px;color: #ccc;">填写双方协商的服务费率</p>
							
								</div>
							</div>
						</form>
					</div>
				</div>
				<div class="modal-footer bdno tac pt0040">
					<button type="button" class=" btn-white clear_btn_style dialog_btn" data-dismiss="modal">取消</button>
					<button type="button" class=" btn-primary clear_btn_style bdno dialog_btn ml30" id="pass_btn"
						style="background-color: #13bc75;">保存</button>
				</div>
			</div>
		</div>
	</div>
	<script>
		layui.use(['layedit', 'laydate', 'table', 'form'], function () {
			var table = layui.table
				, form = layui.form
				, layer = layui.layer
				, layedit = layui.layedit
				, laydate = layui.laydate
				, $ = layui.jquery;
			var shopId = "";
			function getUrlParam(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
				var r = window.location.search.substr(1).match(reg);  //匹配目标参数
				if (r != null) return unescape(r[2]); return null; //返回参数值
			}
			shopId = getUrlParam("id"); //门店id

			$('.user_refuse').text(JSON.parse(sessionStorage.getItem("user_message")).userName); //审核人员
			// 点击拒绝
			$('#refuse_btn').on('click', function () {
				if ($("#refuse_form .reason").eq(0).val().trim() == "") {
					TipsAlert("拒绝原因不能为空!");
					return false;
				}
				var feedbackDetail = $("#refuse_form .reason").val();
				console.log(feedbackDetail)
				$.ajax({
					headers: {
						'X-Access-Token': JSON.parse(sessionStorage.getItem("user_message")).token,
					},
					url: urls + "smallStore/auditProcessing",
					data: {
						id: shopId,
						status: 2,
						feedbackDetails: feedbackDetail
					},
					type: "get",
					success: function (data) {
						CheckLogout(data);         //检查是否登陆过
						if (data.success == true) {
							layer.alert('该商家已拒绝,请返回！', {
								icon: 6
							})
							$('#refuse_dialog').css('display', 'none')
							$('.opera_btn').css('display', 'none')
							$('.ps_btn').css('display', 'none')
						} else {
							TipsAlert(json.msg);
						}
					},
					error: function (data) {
					}
				});
			})


			// 点击通过
			$('#pass_btn').on('click', function () {
				if ($("#pass_form .sever_code").eq(0).val().trim() == "") {
					TipsAlert("服务费不能为空!");
					return false;
				}
				if ($("#pass_form .sever_code").eq(0).val() <= 0) {
					TipsAlert("服务费不可为负数!");
					return false;
				}
				var storeMoney = $("#pass_form .sever_code").val();
				$.ajax({
					headers: {
						'X-Access-Token': JSON.parse(sessionStorage.getItem("user_message")).token,
					},
					url: urls + "smallStore/auditProcessing",
					data: {
						id: shopId,
						status: 1,
						storeMoney: storeMoney
					},
					type: "get",
					success: function (data) {
						CheckLogout(data);         //检查是否登陆过
						if (data.success == true) {
							layer.alert('该商家已通过,请返回！', {
								icon: 6
							})
							$('#pass_dialog').css('display', 'none')
							$('.opera_btn').css('display', 'none')
							$('.ps_btn').css('display', 'none')
						} else {
							TipsAlert(json.msg);
						}
					},
					error: function (data) {
					}
				});
			})


			//审核页面的数据回写
			Showload();
			$.ajax({
				url: urls + "smallStore/storeView",
				headers: {
					'X-Access-Token': JSON.parse(sessionStorage.getItem("user_message")).token,
				},
				data: { id: shopId },
				type: "get",
				dataType: "json",
				contentType: "application/json;charset=UTF-8",
				success: function (data) {
					// console.log(data, '审核页面huix');
					CheckLogout(data); //检查是否登陆过

					if (data.code == 0) {
						$("#time").html(data.data.bSmallStore.createTime);
						$('#storeName').html(data.data.bSmallStore.storeName);
						$('.merchant_name').text(data.data.bSmallStore.storeName) //审核通过的渲染
						$('#storeName2').html(data.data.bSmallStore.storeName);
						$('#papersCreditCode').html(data.data.papersCreditCode);
						$('#storeCertPhone').html(data.data.bSmallStore.storeCustomerPhone);
						$('#loginName').html(data.data.bSmallStore.storePhone);
						$('#storeAlipayCode').html(data.data.bSmallStore.storeAlipayCode);
						$('#storeAlipayName').html(data.data.bSmallStore.storeAlipayName);
						$('#storeCertName').html(data.data.bSmallStore.storeCertName);
						$('#storeAddress').html(data.data.bSmallStore.storeAddress);
						$('#storeCustomerPhone').html(data.data.bSmallStore.storeCertPhone);
						$('#locateInformation').html(data.data.bSmallStore.locateInformation);
						$('#storeMoney').html(data.data.bSmallStore.storeMoney);
						$('#storePic').attr("src", imgUrl + data.data.bSmallStore.storePic); //头像
						// 营业执照
						if (data.data.picList.length > 3) {
							data.data.picList = data.data.picList.slice(0, 3);
						}
						if (data.data.picList.length > 0) {
							// $('#papersPic').attr("src", imgUrl + data.data.picList[0].papersPic);
							var html2 = '';
							for (var i = 0; i < data.data.picList.length; i++) {
								html2 += '<div class="sfz"><img src="' + imgUrl + data.data.picList[i].papersPic + '" onclick="previewImg(this)"></div>'
							}
							$('.businessLicense').html(html2)
						}
						// 门头照片
						$('#storeDecorationPic').attr("src", imgUrl + data.data.bSmallStore.storeDecorationPic);
						// 店内图片数组
						var storeInPicList = data.data.storePicList.filter(v => {
							return v.type == 2
						})
						if (storeInPicList.length > 3) {
							storeInPicList = storeInPicList.slice(0, 3);
						}
						var html = '';
						// 店内照片
						if (storeInPicList.length > 0) {
							for (var i = 0; i < storeInPicList.length; i++) {
								html += '<div class="sfz"><img src="' + imgUrl + storeInPicList[i].storePic + '" onclick="previewImg(this)"></div>'
							}
							$('#storeInPic').html(html);
						}
						// 身份证照片渲染
						var codeInPicList = data.data.storePicList.filter(v => {
							return v.type == 1
						})
						var html1 = '';
						if (codeInPicList.length > 2) {
							var codeInPicList1 = codeInPicList.slice(0, 2);
							for (var i = 0; i < codeInPicList1.length; i++) {
								html1 += '<div class="sfz"><img src="' + imgUrl + codeInPicList1[i].storePic + '" onclick="previewImg(this)"></div>'
							}
							$('#storeInPicCode').html(html1);
						} else {
							for (var i = 0; i < codeInPicList.length; i++) {
								html1 += '<div class="sfz"><img src="' + imgUrl + codeInPicList[i].storePic + '" onclick="previewImg(this)"></div>'
							}
							$('#storeInPicCode').html(html1);
						}
					} else {
						TipsAlert(json.msg);
					}
					InitTime();
				},
				error: function (data) {

				}
			});
		});

		function previewImg(obj) {
			var img = new Image();
			img.src = obj.src;
			//var height = img.height + 50; // 原图片大小
			//var width = img.width; //原图片大小
			var imgHtml = "<img src='" + obj.src + "' width='500px' height='500px'/>";
			//弹出层
			layer.open({
				type: 1,
				shade: 0.8,
				offset: 'auto',
				area: [500 + 'px', 550 + 'px'],  // area: [width + 'px',height+'px']  //原图显示
				shadeClose: true,
				scrollbar: false,
				title: "图片预览", //不显示标题  
				content: imgHtml, //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响  
				cancel: function () {
					//layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', { time: 5000, icon: 6 });  
				}
			});
		}
	</script>
</body>

</html>